package zhang.lao.service.console.base;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import zhang.lao.build.kit.LogKit;
import zhang.lao.dao.base.WnLnglatGt0620180116Dao;
import zhang.lao.build.mybatis.jdbc.auto.model.WnLnglatGt0620180116;
import zhang.lao.build.mybatis.jdbc.auto.model.WnLnglatGt0620180116Example;
import zhang.lao.build.tool.LzStringUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;
import zhang.lao.build.mybatis.jdbc.auto.tool.ControllerQueryTool;
import zhang.lao.pojo.console.req.BootStrapGridReq;
import zhang.lao.pojo.console.resp.BootStrapGridResp;
import zhang.lao.pojo.console.resp.HttpResultUtil;
import zhang.lao.pojo.console.resp.HttpResult;
import javax.annotation.Resource;
import java.util.List;
import zhang.lao.build.tool.UUIDTool;
/**
* 
* @author 
* @create 
**/
 @Service
public class WnLnglatGt0620180116Service{
	@Resource
	private WnLnglatGt0620180116Dao wnLnglatGt0620180116Dao;

	public String add(){
		return "console/wnLnglatGt0620180116/wnLnglatGt0620180116_form";
	}

	public String edit(ModelMap modelMap,java.lang.Integer id){
			modelMap.put("wnLnglatGt0620180116", wnLnglatGt0620180116Dao.selectByPrimaryKey(id));
		return "console/wnLnglatGt0620180116/wnLnglatGt0620180116_form";
	}

	public String list(){
		return "console/wnLnglatGt0620180116/wnLnglatGt0620180116_table";
	}

	public BootStrapGridResp json(BootStrapGridReq bootGridReq){
		Page page = PageHelper.offsetPage(bootGridReq.getOffset(), bootGridReq.getLimit());
    	if(bootGridReq.getSort()!=null) {
    		page.setOrderBy(LzStringUtils.chageStringUpCaseAnd_(bootGridReq.getSort()) + " " + bootGridReq.getOrder());
    	}
		WnLnglatGt0620180116Example wnLnglatGt0620180116Example = new WnLnglatGt0620180116Example();
        ControllerQueryTool.setWnLnglatGt0620180116Criteria(bootGridReq.getQuery(),wnLnglatGt0620180116Example.createCriteria());
		List<WnLnglatGt0620180116> wnLnglatGt0620180116List = wnLnglatGt0620180116Dao.selectByExample(wnLnglatGt0620180116Example);
		return new BootStrapGridResp(page.getTotal(),wnLnglatGt0620180116List);
	}

	public HttpResult save(String formObjectJson){
		WnLnglatGt0620180116 wnLnglatGt0620180116= JSON.parseObject(formObjectJson,WnLnglatGt0620180116.class);
			java.lang.Integer id=wnLnglatGt0620180116.getId();
		if (id!=null) {
			wnLnglatGt0620180116Dao.updateByPrimaryKeySelective(wnLnglatGt0620180116);
		}else{
			wnLnglatGt0620180116Dao.insertSelective(wnLnglatGt0620180116);
		}
		return HttpResultUtil.buildSuccess();

	}

	@Transactional
	public HttpResult delete(String ids){
		String[]idsa=ids.split(",");
		for (String id : idsa) {
		wnLnglatGt0620180116Dao.deleteByPrimaryKey(java.lang.Integer.valueOf(id));
		}
		return HttpResultUtil.buildSuccess();
	}
}
